home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10851 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.7 KB  |  65 lines

  1. Path: uuneo.neosoft.com!usenet
  2. From: Wmatthew@lan-aces.com (W. Matthews)
  3. Newsgroups: comp.lang.c++,comp.lang.c++.mederated
  4. Subject: Re: Problems with "multiple defined" at linking stage
  5. Date: 11 Mar 1996 15:18:37 GMT
  6. Organization: LAN-ACES, Inc.
  7. Message-ID: <4i1g8d$b7i@uuneo.neosoft.com>
  8. References: <1996Mar6.144651.26841@ucl.ac.uk>
  9. NNTP-Posting-Host: 198.65.178.8
  10. X-Newsreader: WinVN 0.92.5
  11.  
  12. In article <1996Mar6.144651.26841@ucl.ac.uk>, richard@nmr.ion.bpmf.ac.uk (Mr Richard Maunder) says:
  13. >
  14. >I am trying to build a C++ patch over a C function library, but am encountering some problems at the linking stage, where the ld reports : 
  15. >
  16. >collect2: ld returned 2 exit status
  17. >ld: /usr/tmp/cca176282.o: __imerrbuf: multiply defined
  18. >
  19. >I presume this is caused by a multiple include in the code, but I cannot see a way round it.  The compiler (g++) makes no complaints when creating the obj
  20. >
  21. >The files I have are :
  22. >
  23. >        1) unc_c++_patch .h - The header for the patch.  This had the standard :
  24. >
  25. >                #ifndef UNC_CPLUSPLUS_PATCH
  26. >                #define UNC_CPLUSPLUS_PATCH
  27. >
  28. >                extern "C" {
  29. >                        #include "image.h"
  30. >                }
  31. >
  32. >                ......protyping for C++ methods.
  33. >
  34. >                #endif
  35. >
  36. >        in it. The file image.h is the header for the C function library.
  37. >
  38. >        2) unc_c++_patch.cc - The methods for the C++ patch. Has a #include unc_c++_patch.h at the top.
  39. >
  40. >        3) simple.cc - The actual program - again has unc_c++_patch.h at top.
  41. >
  42. >I presume I should be able to compile unc_c++_patch.cc and simple.cc seperately and then link them, but won't the compiler include "image.h" both times - 
  43. >
  44. >I hope that I'm not being too stupid ! Any help gartefully recieved...Please CC tany replies o my e-mail address.
  45. >
  46. >Thanks
  47. >
  48. >
  49. >Richard
  50.  
  51. I have seen a similar thing a time or two with MS VC/C++.  The objects compile successfully separately, but will not
  52. link (especially if the header has the structure of a class, or a variable in it).
  53. The only reasoning I can see is that when they are compiled, the preprocessor does not see the
  54. variable (UNC_CPLUSPLUS_PATCH) defined any where.  But when linked, there are now two definitions
  55. (albeit the same) for everything that is in the header file (and anything included & used through it)
  56. ______________________________________________
  57. |Wyatt Matthews:       Tech Support Department |
  58. |WMATTHEW@LAN-ACES.COM        -Internet-       |
  59. |WMATTHEW.MHS@LAN-ACES          -MHS-          |
  60. |LAN-ACES Tech Support      (713)890-9786      |
  61. |LAN-ACES BBS               (713)890-9790      |
  62. |LAN-ACES Fax               (713)890-9731      |
  63. |LAN-ACES Sales             (713)890-9787      |
  64. ______________________________________________
  65.